package logic

import (
	"context"
	"errors"
	"srv/models/mysqlinit"

	"srv/internal/svc"
	"srv/srv"

	"github.com/zeromicro/go-zero/core/logx"
)

type AdmExamineLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAdmExamineLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdmExamineLogic {
	return &AdmExamineLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *AdmExamineLogic) AdmExamine(in *srv.AdmExamineRequest) (*srv.AdmExamineResponse, error) {
	// todo: add your logic here and delete this line
	u := mysqlinit.User{}
	u.Status = int(in.Status)
	err := u.UpdateUser(in.UserId, in.Status)
	if err != nil {
		logx.Error("用户发布权限审核失败")
		return nil, errors.New("用户发布权限审核失败")
	}
	return &srv.AdmExamineResponse{
		Type: true,
	}, nil
}
